import Vue from 'vue';
import Vuex from 'vuex';
import createLogger from '../plugins/logger';

Vue.use(Vuex);

const debug = process.env.NODE_ENV !== 'production';
const modules = require.context('./modules', false, /\.js$/);

export default new Vuex.Store({
  modules: modules.keys().reduce((acc, key) => ({ ...acc, [key.replace(/(\.\/|\.js)/g, '')]: modules(key).default }), {}),
  state: {
    chainId: '',
    currentAddress: '',
    isShowAside: false,
    theme: 'light',
  },
  getters: {
  },
  mutations: {
    updateChainId(state, data) {
      state.chainId = data;
    },
    updateCurrentAddress(state, data) {
      state.currentAddress = data;
    },
    updateIsShowAside(state, data) {
      state.isShowAside = data;
    },
    updateTheme(state, data) {
      state.theme = data;
    },
  },
  actions: {
  },
  strict: debug,
  // plugins: debug ? [createLogger()] : [],
  plugins: [],
});
